package com.qlslylq.ad.sdk.core.loader;

import android.app.Activity;
import android.app.AlertDialog;

import com.bytedance.sdk.openadsdk.AdSlot;
import com.bytedance.sdk.openadsdk.TTAdConstant;
import com.bytedance.sdk.openadsdk.TTAdLoadType;
import com.bytedance.sdk.openadsdk.TTAdNative;
import com.bytedance.sdk.openadsdk.TTFullScreenVideoAd;
import com.kwad.sdk.api.KsFullScreenVideoAd;
import com.kwad.sdk.api.KsInterstitialAd;
import com.kwad.sdk.api.KsLoadManager;
import com.kwad.sdk.api.KsScene;
import com.kwad.sdk.api.KsVideoPlayConfig;
import com.kwad.sdk.api.SdkConfig;
import com.mbridge.msdk.MBridgeConstans;
import com.mbridge.msdk.newinterstitial.out.MBNewInterstitialHandler;
import com.mbridge.msdk.newinterstitial.out.NewInterstitialListener;
import com.mbridge.msdk.out.MBridgeIds;
import com.mbridge.msdk.out.RewardInfo;
import com.qlslylq.ad.sdk.config.CsjMgrHolder;
import com.qlslylq.ad.sdk.config.KsMgrHolder;
import com.qlslylq.ad.sdk.constant.AppConst;
import com.qlslylq.ad.sdk.constant.UrlConst;
import com.qlslylq.ad.sdk.core.ad.BaseAd;
import com.qlslylq.ad.sdk.core.interceptor.UnifiedInterstitialADListener;
import com.qlslylq.ad.sdk.core.interceptor.WindInterstitialAdListener;
import com.qlslylq.ad.sdk.core.listener.InterstitialAdListener;
import com.qlslylq.ad.sdk.core.mgr.PoolMgr;
import com.qlslylq.ad.sdk.core.rsp.AdError;
import com.qlslylq.ad.sdk.enums.AdEventSign;
import com.qlslylq.ad.sdk.enums.AdPlatformEnum;
import com.qlslylq.ad.sdk.enums.ErrorEnum;
import com.qlslylq.ad.sdk.model.req.UserBehaviorAddDTO;
import com.qlslylq.ad.sdk.model.rsp.AdPlaceWebConfigureVO;
import com.qlslylq.ad.sdk.net.api.ApiServiceImpl;
import com.qlslylq.ad.sdk.util.DecimalUtils;
import com.qlslylq.ad.sdk.util.GsonUtils;
import com.qlslylq.ad.sdk.util.Log;
import com.qlslylq.ad.sdk.util.PlatformUtils;
import com.qq.e.ads.cfg.VideoOption;
import com.qq.e.ads.interstitial2.UnifiedInterstitialAD;
import com.qq.e.ads.interstitial2.UnifiedInterstitialMediaListener;
import com.sigmob.windad.WindAdError;
import com.sigmob.windad.interstitial.WindInterstitialAd;
import com.sigmob.windad.interstitial.WindInterstitialAdRequest;

import java.lang.reflect.Field;
import java.util.List;

import static com.qlslylq.ad.sdk.enums.OrientationEnum.LANDSCAPE;
import static com.qlslylq.ad.sdk.enums.OrientationEnum.PORTRAIT;

/**
 * 插屏广告加载器<br/>
 */
public class InterstitialAdLoader extends AdLoader<InterstitialAdListener> {

    //声音策略(默认策略：静音)
    private boolean autoPlayMuted;

    public InterstitialAdLoader(Activity context, long posId, InterstitialAdListener adListener) {
        this(context, posId, true, adListener);
    }

    public InterstitialAdLoader(Activity context, long posId, boolean autoPlayMuted, InterstitialAdListener adListener) {
        super(context, posId, adListener);
        this.autoPlayMuted = autoPlayMuted;
    }

    /**
     * 加载并展示<br/>
     */
    protected void load(AdPlaceWebConfigureVO config) {
        AdPlatformEnum platform = config.getPlatform();
        String posId = config.getPositionId();

        if (platform == AdPlatformEnum.PLATFORM_CSJ) {//穿山甲
            AdSlot adSlot = new AdSlot.Builder()
                    .setCodeId(posId)
                    .setOrientation(orientation == PORTRAIT ? TTAdConstant.VERTICAL : TTAdConstant.HORIZONTAL)//方向由创建时决定，且不能改变，此处应可省
                    .setExpressViewAcceptedSize(AppConst.CSJ_INTERSTITIAL_SIZE_W, AppConst.CSJ_INTERSTITIAL_SIZE_H)//提供竖图比例
                    .setAdLoadType(TTAdLoadType.PRELOAD)//[实时加载，预加载]
                    .setSupportDeepLink(true)
                    .build();
            CsjMgrHolder.createAdNative(context).loadFullScreenVideoAd(adSlot, new TTAdNative.FullScreenVideoAdListener() {
                @Deprecated
                public void onFullScreenVideoCached() {

                }

                public void onFullScreenVideoCached(TTFullScreenVideoAd ad) {

                }

                public void onFullScreenVideoAdLoad(TTFullScreenVideoAd ad) {
                    PoolMgr.getInstance().push(ad, config);

                    getAdListener().onAdLoad();

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_RETURN_SUCCESS, InterstitialAdLoader.super.posId));
                }

                public void onError(int code, String msg) {
                    Log.e(GsonUtils.gsonString(AdError.build(platform, adType, code, msg)));
                    getAdListener().onAdLoadError(AdError.build(platform, adType, code, msg));

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_RETURN_FAIL, InterstitialAdLoader.super.posId));
                }
            });

        } else if (platform == AdPlatformEnum.PLATFORM_YLH) {//优量汇
            PoolMgr.getInstance().push(new Object(), config);
        } else if (platform == AdPlatformEnum.PLATFORM_KS) {//快手联盟
            boolean isHalf = config.isHalf();
            KsScene scene = new KsScene.Builder(DecimalUtils.parseLongSafe(posId))
                    .setBackUrl(UrlConst.BACK_URL_AD) // scheme逆向唤醒协议名设置，与清单中所注册的协议名保持一致即可
                    .screenOrientation(orientation == PORTRAIT ? SdkConfig.SCREEN_ORIENTATION_PORTRAIT : SdkConfig.SCREEN_ORIENTATION_LANDSCAPE)//不起决定性
                    .build();
            if (isHalf) {
                KsMgrHolder.get().loadInterstitialAd(scene, new KsLoadManager.InterstitialAdListener() {
                    public void onInterstitialAdLoad(List<KsInterstitialAd> list) {
                        try {
                            if (list == null || list.isEmpty()) {
                                return;
                            }
                            KsInterstitialAd ad = list.get(0);

                            PoolMgr.getInstance().push(ad, config);

                            getAdListener().onAdLoad();
                        } catch (Exception e) {
                            e.printStackTrace();
                            Log.e(GsonUtils.gsonString(ErrorEnum.ERR_NO_AD.rsp(platform, adType)));
                            getAdListener().onAdLoadError(ErrorEnum.ERR_NO_AD.rsp(platform, adType));
                        }

                        ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_RETURN_SUCCESS, InterstitialAdLoader.super.posId));
                    }

                    public void onRequestResult(int adNumber) {

                    }

                    public void onError(int code, String msg) {
                        Log.e(GsonUtils.gsonString(AdError.build(platform, adType, code, msg)));
                        getAdListener().onAdLoadError(AdError.build(platform, adType, code, msg));

                        ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_RETURN_FAIL, InterstitialAdLoader.super.posId));
                    }
                });
            } else {
                KsMgrHolder.get().loadFullScreenVideoAd(scene, new KsLoadManager.FullScreenVideoAdListener() {
                    public void onFullScreenVideoAdLoad(List<KsFullScreenVideoAd> list) {
                        try {
                            KsFullScreenVideoAd ad = list.get(0);

                            PoolMgr.getInstance().push(ad, config);

                            getAdListener().onAdLoad();
                        } catch (Exception e) {
                            e.printStackTrace();
                            Log.e(GsonUtils.gsonString(ErrorEnum.ERR_NO_AD.rsp(platform, adType)));
                            getAdListener().onAdLoadError(ErrorEnum.ERR_NO_AD.rsp(platform, adType));
                        }

                        ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_RETURN_SUCCESS, InterstitialAdLoader.super.posId));
                    }

                    public void onRequestResult(int adNumber) {

                    }

                    public void onError(int code, String msg) {
                        Log.e(GsonUtils.gsonString(AdError.build(platform, adType, code, msg)));
                        getAdListener().onAdLoadError(AdError.build(platform, adType, code, msg));

                        ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_RETURN_FAIL, InterstitialAdLoader.super.posId));
                    }
                });
            }
        } else if (platform == AdPlatformEnum.PLATFORM_SIGMOB) {//SigMob的插屏广告位最好是配置到全屏广告位中
            WindInterstitialAdRequest request = new WindInterstitialAdRequest(posId, null, null);
            WindInterstitialAdListener listener = new WindInterstitialAdListener() {
                public void onInterstitialAdPreLoadSuccess(String placementId) {

                }

                public void onInterstitialAdPreLoadFail(String placementId) {

                }

                public void onInterstitialAdLoadSuccess(String placementId) {
                    PoolMgr.getInstance().push(getAd(), config);

                    getAdListener().onAdLoad();

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_RETURN_SUCCESS, InterstitialAdLoader.super.posId));
                }

                public void onInterstitialAdPlayStart(String placementId) {
                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_EXPOSURE, InterstitialAdLoader.super.posId));
                }

                public void onInterstitialAdPlayEnd(final String placementId) {
                    getAdListener().onAdComplete();
                }

                public void onInterstitialAdClicked(String placementId) {
                    getAdListener().onAdClick();

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_CLICK, InterstitialAdLoader.super.posId));
                }

                public void onInterstitialAdClosed(String placementId) {
                    getAdListener().onAdDismiss();

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_CLOSE, InterstitialAdLoader.super.posId));
                }

                public void onInterstitialAdLoadError(WindAdError error, String placementId) {
                    Log.e(GsonUtils.gsonString(AdError.build(platform, adType, error.getErrorCode(), error.getMessage())));
                    getAdListener().onAdLoadError(AdError.build(platform, adType, error.getErrorCode(), error.getMessage()));

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_RETURN_FAIL, InterstitialAdLoader.super.posId));
                }

                public void onInterstitialAdPlayError(WindAdError error, String placementId) {
                    Log.e(GsonUtils.gsonString(AdError.build(platform, adType, error.getErrorCode(), error.getMessage())));
                    onAdShowErrorSafety(AdError.build(platform, adType, error.getErrorCode(), error.getMessage()), platform, true);
                }
            };
            WindInterstitialAd ad = new WindInterstitialAd(context, request);
            listener.setAd(ad);
            ad.setWindInterstitialAdListener(listener);
            ad.loadAd();
        } else if (platform == AdPlatformEnum.PLATFORM_MINTEGRAL) {
            MBNewInterstitialHandler ad = new MBNewInterstitialHandler(context, null, posId);
            ad.setInterstitialVideoListener(new NewInterstitialListener() {
                public void onLoadCampaignSuccess(MBridgeIds ids) {
                }

                public void onResourceLoadSuccess(MBridgeIds ids) {
                    PoolMgr.getInstance().push(ad, config);

                    getAdListener().onAdLoad();

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_RETURN_SUCCESS, InterstitialAdLoader.super.posId));
                }

                public void onResourceLoadFail(MBridgeIds ids, String msg) {
                    Log.e(GsonUtils.gsonString(AdError.build(platform, adType, ErrorEnum.ERR_LOAD_FAILD.getId(), msg)));
                    getAdListener().onAdLoadError(AdError.build(platform, adType, ErrorEnum.ERR_LOAD_FAILD.getId(), msg));

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_RETURN_FAIL, InterstitialAdLoader.super.posId));
                }

                public void onShowFail(MBridgeIds ids, String msg) {
                    Log.e(GsonUtils.gsonString(AdError.build(platform, adType, ErrorEnum.ERR_SHOW_FAILD.getId(), msg)));
                    onAdShowErrorSafety(AdError.build(platform, adType, ErrorEnum.ERR_SHOW_FAILD.getId(), msg), platform, true);
                }

                public void onAdShow(MBridgeIds ids) {
                    onAdShowSafety();
                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_EXPOSURE, InterstitialAdLoader.super.posId));
                }

                public void onAdClose(MBridgeIds ids, RewardInfo info) {
                    getAdListener().onAdDismiss();

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_CLOSE, InterstitialAdLoader.super.posId));
                }

                public void onAdClicked(MBridgeIds ids) {
                    getAdListener().onAdClick();

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_CLICK, InterstitialAdLoader.super.posId));
                }

                public void onVideoComplete(MBridgeIds ids) {
                    getAdListener().onAdComplete();
                }

                public void onAdCloseWithNIReward(MBridgeIds ids, RewardInfo info) {
                }

                public void onEndcardShow(MBridgeIds ids) {
                }
            });
            ad.load();
        }
    }

    protected void show(BaseAd ad) {
        AdPlaceWebConfigureVO config = ad.getConfig();
        AdPlatformEnum platform = config.getPlatform();
        String posId = config.getPositionId();

        if (platform == AdPlatformEnum.PLATFORM_CSJ) {//穿山甲
            TTFullScreenVideoAd adThird = (TTFullScreenVideoAd) ad.getAd();
            adThird.setFullScreenVideoAdInteractionListener(new TTFullScreenVideoAd.FullScreenVideoAdInteractionListener() {
                public void onAdShow() {
                    onAdShowSafety();

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_EXPOSURE, InterstitialAdLoader.super.posId));
                }

                public void onVideoComplete() {
                    getAdListener().onAdComplete();
                }

                public void onAdClose() {
                    getAdListener().onAdDismiss();

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_CLOSE, InterstitialAdLoader.super.posId));
                }

                public void onSkippedVideo() {

                }

                public void onAdVideoBarClick() {//广告下载bar点击
                    getAdListener().onAdClick();

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_CLICK, InterstitialAdLoader.super.posId));
                }
            });

            adThird.showFullScreenVideoAd(context, TTAdConstant.RitScenes.CUSTOMIZE_SCENES, null);

        } else if (platform == AdPlatformEnum.PLATFORM_YLH) {//优量汇
            UnifiedInterstitialADListener listener = new UnifiedInterstitialADListener() {
                public void onADOpened() {

                }

                public void onVideoCached() {

                }

                public void onADReceive() {
                    getAdListener().onAdLoad();

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_RETURN_SUCCESS, InterstitialAdLoader.super.posId));
                }

                public void onRenderSuccess() {
                    getAd().show();
                    onAdShowSafety();
                }

                public void onADExposure() {
                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_EXPOSURE, InterstitialAdLoader.super.posId));
                }

                public void onADLeftApplication() {

                }

                public void onADClosed() {
                    getAdListener().onAdDismiss();

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_CLOSE, InterstitialAdLoader.super.posId));
                }

                public void onADClicked() {
                    getAdListener().onAdClick();

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_CLICK, InterstitialAdLoader.super.posId));
                }

                public void onRenderFail() {
                    Log.e(GsonUtils.gsonString(ErrorEnum.ERR_RENDER.rsp(platform, adType)));
                    onAdShowErrorSafety(ErrorEnum.ERR_RENDER.rsp(platform, adType), platform, true);
                }

                public void onNoAD(com.qq.e.comm.util.AdError error) {
                    Log.e(GsonUtils.gsonString(AdError.build(platform, adType, error.getErrorCode(), error.getErrorMsg())));
                    getAdListener().onAdLoadError(AdError.build(platform, adType, error.getErrorCode(), error.getErrorMsg()));

                    ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_RETURN_FAIL, InterstitialAdLoader.super.posId));
                }
            };
            UnifiedInterstitialAD adYlh = new UnifiedInterstitialAD(context, posId, listener);
            listener.setAd(adYlh);
            VideoOption option = new VideoOption.Builder()
                    .setAutoPlayMuted(autoPlayMuted)//声音策略
                    .setAutoPlayPolicy(VideoOption.AutoPlayPolicy.ALWAYS)//非WiFi环境下的声音策略
                    .setDetailPageMuted(false)
                    .build();
            adYlh.setVideoOption(option);
            adYlh.setMediaListener(new UnifiedInterstitialMediaListener() {//监听视频广告的状态变化
                public void onVideoInit() {

                }

                public void onVideoLoading() {

                }

                public void onVideoReady(long videoDuration) {

                }

                public void onVideoStart() {

                }

                public void onVideoPause() {

                }

                public void onVideoComplete() {
                    getAdListener().onAdComplete();
                }

                public void onVideoPageOpen() {

                }

                public void onVideoPageClose() {

                }

                public void onVideoError(com.qq.e.comm.util.AdError error) {
                    Log.e(GsonUtils.gsonString(AdError.build(platform, adType, error.getErrorCode(), error.getErrorMsg())));
                    onAdShowErrorSafety(AdError.build(platform, adType, error.getErrorCode(), error.getErrorMsg()), platform, true);
                }
            });
            adYlh.loadAD();
        } else if (platform == AdPlatformEnum.PLATFORM_KS) {//快手联盟
            boolean isHalf = config.isHalf();
            if (isHalf) {
                KsInterstitialAd adThird = (KsInterstitialAd) ad.getAd();
                KsVideoPlayConfig videoPlayConfig = new KsVideoPlayConfig.Builder()
                        .showLandscape(orientation == LANDSCAPE)//方向
                        .videoSoundEnable(!autoPlayMuted)//声音策略
                        .build();
                adThird.setAdInteractionListener(new KsInterstitialAd.AdInteractionListener() {
                    public void onAdShow() {
                        try {
                            Class<?> adClass = adThird.getClass();
                            Field field = adClass.getDeclaredField(PlatformUtils.getKsDialogClassName());
                            field.setAccessible(true);
                            AlertDialog dialog = (AlertDialog) field.get(adThird);
                            dialog.setCancelable(true);
                            dialog.setCanceledOnTouchOutside(true);
                            dialog.setOnKeyListener((dialogInterface, i, keyEvent) -> {
                                if (i == keyEvent.KEYCODE_BACK) {
                                    dialog.dismiss();
                                    return true;
                                }
                                return false;
                            });
                        } catch (Exception e) {
                            e.printStackTrace();
                            Log.e("测试", "e:" + e);
                        }

                        onAdShowSafety();

                        ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_EXPOSURE, InterstitialAdLoader.super.posId));
                    }

                    public void onAdClosed() {
                    }

                    public void onVideoPlayStart() {
                    }

                    public void onVideoPlayEnd() {
                        getAdListener().onAdComplete();
                    }

                    public void onPageDismiss() {
                        getAdListener().onAdDismiss();

                        ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_CLOSE, InterstitialAdLoader.super.posId));
                    }

                    public void onSkippedAd() {
                    }

                    public void onAdClicked() {
                        getAdListener().onAdClick();

                        ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_CLICK, InterstitialAdLoader.super.posId));
                    }

                    public void onVideoPlayError(int code, int extra) {
                        Log.e(GsonUtils.gsonString(AdError.build(platform, adType, code, String.valueOf(extra))));
                        onAdShowErrorSafety(AdError.build(platform, adType, code, String.valueOf(extra)), platform, true);
                    }
                });
                adThird.showInterstitialAd(context, videoPlayConfig);
            } else {
                KsFullScreenVideoAd adThird = (KsFullScreenVideoAd) ad.getAd();
                KsVideoPlayConfig videoPlayConfig = new KsVideoPlayConfig.Builder()
                        .showLandscape(orientation == LANDSCAPE)//方向
                        .videoSoundEnable(true)//声音策略
                        .build();
                adThird.setFullScreenVideoAdInteractionListener(new KsFullScreenVideoAd.FullScreenVideoAdInteractionListener() {
                    public void onVideoPlayStart() {
                        onAdShowSafety();

                        ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_EXPOSURE, InterstitialAdLoader.super.posId));
                    }

                    public void onVideoPlayEnd() {
                        getAdListener().onAdComplete();
                    }

                    public void onPageDismiss() {
                        getAdListener().onAdDismiss();

                        ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_CLOSE, InterstitialAdLoader.super.posId));
                    }

                    public void onSkippedVideo() {

                    }

                    public void onAdClicked() {
                        getAdListener().onAdClick();

                        ApiServiceImpl.addTrack(UserBehaviorAddDTO.build(config, AdEventSign.AD_CLICK, InterstitialAdLoader.super.posId));
                    }

                    public void onVideoPlayError(int code, int extra) {
                        Log.e(GsonUtils.gsonString(AdError.build(platform, adType, code, String.valueOf(extra))));
                        onAdShowErrorSafety(AdError.build(platform, adType, code, String.valueOf(extra)), platform, false);
                    }
                });
                adThird.showFullScreenVideoAd(context, videoPlayConfig);
            }
        } else if (platform == AdPlatformEnum.PLATFORM_SIGMOB) {
            WindInterstitialAd adThird = (WindInterstitialAd) ad.getAd();
            if (adThird.isReady()) {
                adThird.show(context, null);
            } else {
                Log.e(GsonUtils.gsonString(ErrorEnum.ERR_NOT_READY.rsp(platform, adType)));
                onAdShowErrorSafety(ErrorEnum.ERR_NOT_READY.rsp(platform, adType), platform, true);
            }
        } else if (platform == AdPlatformEnum.PLATFORM_MINTEGRAL) {
            MBNewInterstitialHandler adThird = (MBNewInterstitialHandler) ad.getAd();
            adThird.playVideoMute(autoPlayMuted ? MBridgeConstans.REWARD_VIDEO_PLAY_MUTE : MBridgeConstans.REWARD_VIDEO_PLAY_NOT_MUTE);
            if (adThird.isReady()) {
                adThird.show();
            } else {
                Log.e(GsonUtils.gsonString(ErrorEnum.ERR_NOT_READY.rsp(platform, adType)));
                onAdShowErrorSafety(ErrorEnum.ERR_NOT_READY.rsp(platform, adType), platform, true);
            }
        }
    }

    /**
     * 设置声音策略<br/>
     */
    public void setAutoPlayMuted(boolean autoPlayMuted) {
        this.autoPlayMuted = autoPlayMuted;
    }

}
